﻿//You can change this to feet your needs, just please keep giving credits to the author
//Thanks
//	DarkAngel  ( DarkAngel@IdleZone.Org )

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DarkRuler
{
	public partial class FormOptions : Form
	{
		public FormOptions()
		{
			InitializeComponent();
			textBox1.Text = Config.BoxSizeInCm.ToString();
			textBox2.Text = Config.BoxXSize_InPixel.ToString();
			textBox3.Text = Config.BoxYSize_InPixel.ToString();
			checkBox1.Checked = Config.AutoUpdate;
			checkBox2.Checked = Config.UsePointForBox;
			checkBox3.Checked = Config.UseButtonsForZoom;
		}
		private void FormOptions_Closing(object sender, CancelEventArgs e)
		{
			Config.Reload();
		}

		private void menuItem1_Click(object sender, EventArgs e)
		{
			try
			{
				Config.BoxSizeInCm = double.Parse(textBox1.Text);
			}
			catch { MessageBox.Show("Please enter a numeric value for BoxSizeInCm!", "DarkRuler", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); }
			try
			{
				Config.BoxXSize_InPixel = double.Parse(textBox2.Text);
			}
			catch { MessageBox.Show("Please enter a numeric value for BoxXSize_InPixel!", "DarkRuler", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); }
			try
			{
				Config.BoxYSize_InPixel = double.Parse(textBox3.Text);
			}
			catch { MessageBox.Show("Please enter a numeric value for BoxYSize_InPixel!", "DarkRuler", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); }
			Config.AutoUpdate = checkBox1.Checked;
			Config.UseButtonsForZoom = checkBox3.Checked;
			Config.Save();
			this.Close();
		}

		private void menuItemCancel_Click(object sender, EventArgs e)
		{
			Config.Reload();
			this.Close();
		}
	}
}